﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Sys_Param_Edit.aspx.cs" Inherits="SYS_POPEDOM_Sys_Param_Edit" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .no-icon
        {
            display: none;
        }
    </style>
    <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="../JavaScript/Common.js"></script>

    <script type="text/javascript">
        function nodeLoad(node) {
            Ext.net.DirectMethods.NodeLoad(node.id, {
                success: function(result) {
                    var data = eval("(" + result + ")");
                    node.loadNodes(data);
                },

                failure: function(errorMsg) {
                    Ext.Msg.alert('Failure', errorMsg);
                }
            });
        }

        function PopDeptWin() {
            popWindow.show();
        }

        function SaveWin() {
            getCheckedNode2();
            Ext.getCmp('exttrig_DEPT_Name').setValue(strDeptName);
            Ext.getCmp('exttxtf_DeptID').setValue(strResult);
            strResult = "";
            strDeptName = "";
            ClostWin();
        }

        function ClostWin() {
            popWindow.hide();
        }

        var strResult = "";
        var strDeptName = "";
        function getChkedNode(node) {
            if (node.getUI().isChecked()) {
                strResult = strResult + Trim(node.id) + ",";
                strDeptName = strDeptName + Trim(node.text) + ",";
            }
            var chileNodes = node.childNodes;
            for (var i = 0; i < chileNodes.length; i++) {
                getChkedNode(chileNodes[i]);
            }
        }

        function getCheckedNode2() {
            getChkedNode(Ext.getCmp('TreePanel1').root);
            if (strResult.length > 0) {
                strResult = strResult.substring(0, strResult.length - 1);
            }
            if (strDeptName.length > 0) {
                strDeptName = strDeptName.substring(0, strDeptName.length - 1);
            }
        }

        function CheckExpandNode(node) {
            var sDept = Ext.getCmp('exttxtf_DeptID').getValue();//value;
            var sArray = sDept.split(',');
            for (var ii = 0; ii < sArray.length; ii++) {
                if (sArray[ii] == Trim(node.id)) {
                    node.getUI().checkbox.checked = true;
                }
            }
            for (var i = 0; i < node.childNodes.length; i++) {
                for (var j = 0; j < sArray.length; j++) {
                    if (sArray[j] == Trim(node.childNodes[i].id)) {
                        node.childNodes[i].getUI().checkbox.checked = true;
                    }
                }
            }
        }
    </script>

</head>
<body class="backcolor">
    <form id="form1" runat="server">
    <div>
    </div>
    <ext:ResourceManager ID="ScriptManager1" runat="server">
    </ext:ResourceManager>
    <ext:Store ID="Store1" runat="server" AutoLoad="true">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="SUB_SYSTEM">
                    </ext:RecordField>
                    <ext:RecordField Name="SYSTEM_NAME">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server">
        <Content>
            <%--<ext:FitLayout ID="FitLayout1" runat="server">--%>
                <ext:FormPanel ID="FormPanel1" runat="server" BodyStyle="padding:3px;" ButtonAlign="Center"
                    Frame="false" BodyBorder="false" Title="">
                    <Content>
                        <ext:FormLayout ID="FormLayout1" runat="server"><Anchors>
                            <ext:Anchor Horizontal="95%">
                                <ext:TextField ID="exttxtf_PARAMETER_ID" runat="server" FieldLabel="参数编号" LabelStyle=" text-align:right; "
                                    AllowBlank="false" MaxLength="20">
                                </ext:TextField>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:TextField ID="exttxtf_PARAMETER_NAME" runat="server" FieldLabel="参数名称" LabelStyle=" text-align:right; "
                                    AllowBlank="false" MaxLength="40">
                                </ext:TextField>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:TextField ID="exttxtf_PARAMETER_NOTE" runat="server" FieldLabel="参数说明" LabelStyle=" text-align:right; ">
                                </ext:TextField>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="20%">
                                <ext:ComboBox ID="extcmbo_PARAMETER_TYPE" runat="server" FieldLabel="参数类型" LabelStyle=" text-align:right; "
                                    Editable="false" ForceSelection="true" SelectedIndex="0">
                                    <Items>
                                        <ext:ListItem Value="1" Text="编辑框" />
                                        <ext:ListItem Value="2" Text="选项" />
                                    </Items>
                                    <DirectEvents>
                                        <Select OnEvent="OnParamTypeChange">
                                        </Select>
                                    </DirectEvents>
                                </ext:ComboBox>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:TextArea ID="exttare_PARAMETER_OPTION" runat="server" FieldLabel="参数选项" LabelStyle=" text-align:right;">
                                </ext:TextArea>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:TriggerField ID="exttrig_DEPT_Name" runat="server" FieldLabel="设置部门" LabelStyle=" text-align:right;"
                                     Editable="false">
                                    <Listeners>
                                        <TriggerClick Fn="PopDeptWin" />
                                    </Listeners>
                                </ext:TriggerField>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="20%">
                                <ext:ComboBox ID="extcmbo_SUB_SYSTEM" runat="server" FieldLabel="应用子系统" LabelStyle=" text-align:right; "
                                    StoreID="Store1" DisplayField="SYSTEM_NAME" ValueField="SUB_SYSTEM" Editable="true"
                                    TriggerAction="All" Mode="Local" TypeAhead="true">
                                </ext:ComboBox>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:RadioGroup ID="extrdio_SHOW_FLAG" runat="server" FieldLabel="显示" LabelStyle=" text-align:right; "
                                    ColumnsWidths="50,50">
                                    <Items>
                                        <ext:Radio ID="extrdio_1" runat="server" BoxLabel="是" Checked="true">
                                        </ext:Radio>
                                        <ext:Radio ID="extrdio_2" runat="server" BoxLabel="否">
                                        </ext:Radio>
                                    </Items>
                                </ext:RadioGroup>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:TextArea ID="exttare_REMARK" runat="server" FieldLabel="备注" LabelStyle=" text-align:right;">
                                </ext:TextArea>
                            </ext:Anchor>
                            <ext:Anchor Horizontal="95%">
                                <ext:TextField ID="exttxtf_DeptID" runat="server" Hidden="true">
                                </ext:TextField>
                            </ext:Anchor>
                            </Anchors>
                        </ext:FormLayout>
                    </Content>
                    <TopBar>
                        <ext:Toolbar runat="server">
                            <Items>
                                <ext:Button ID="extBtnSave" runat="server" Icon="Accept" Text="保存">
                                    <DirectEvents>
                                        <Click OnEvent="SaveSysParam">
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="extBtnCancel" runat="server" Icon="Cancel" Text="关闭">
                                    <Listeners>
                                        <Click Fn="closeCurrTab" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                </ext:FormPanel>
            <%--</ext:FitLayout>--%>
        </Content>
    </ext:Viewport>
    <ext:Window ID="popWindow" runat="server" Icon="Group" Title="" Width="400" Height="380"
        AutoShow="false" Modal="true" ShowOnLoad="false" Closable="true" Resizable="true"
        Draggable="false" Hidden="true" >
        <Content>
            <%--<ext:FitLayout ID="FitLayout3" runat="server">--%>
                <ext:Panel ID="Panel2" runat="server" Border="false">
                    <Content>
                        <%--<ext:FitLayout ID="FitLayout2" runat="server">--%>
                            <ext:TreePanel ID="TreePanel1" runat="server" Lines="false" Border="false" BodyStyle="background-color:#f0f0f0;"
                                CollapseFirst="false" AutoScroll="true" ContainerScroll="true" Layout="FitLayout">
                                <LoadMask ShowMask="true" />
                                <Listeners>
                                    <BeforeLoad Fn="nodeLoad" />
                                    <ExpandNode Fn="CheckExpandNode" />
                                </Listeners>
                            </ext:TreePanel>
                        <%--</ext:FitLayout>--%>
                    </Content>
                </ext:Panel>
            <%--</ext:FitLayout>--%>
        </Content>
        <BottomBar>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:ToolbarFill ID="ToolbarFill1" runat="server">
                    </ext:ToolbarFill>
                    <ext:Button ID="btnSave" runat="server" Text="确定" Icon="Disk">
                        <Listeners>
                            <Click Fn="SaveWin" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnCancel" runat="server" Text="关闭" Icon="Cancel">
                        <Listeners>
                            <Click Fn="ClostWin" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnExpand" runat="server" Hidden="true">
                        <Listeners>
                            <Click Handler="#{TreePanel1}.expandAll();" />
                        </Listeners>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </BottomBar>
    </ext:Window>
    </form>
</body>
</html>
